﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace flying_fish
{
    internal class data
    {
        public static void save_data_dialog(RichTextBox rtb)
        {
            SaveFileDialog saveDataDialog = new SaveFileDialog();
            saveDataDialog.InitialDirectory = System.Windows.Forms.Application.StartupPath;
            string yyyyMMddhh = DateTime.Now.ToString("yyyy-MM-dd-HH-mm-ss");
            saveDataDialog.FileName = yyyyMMddhh;
            saveDataDialog.Title = "保存数据文件";
            saveDataDialog.AddExtension = true;
            saveDataDialog.Filter = "RTF文件(*.rtf)|*.rtf";
            //saveDataDialog.Filter = "Excel (*.xlsx)|*.xlsx|Text Files (*.txt)|*.txt|Csv Files (*.csv)|*.csv";
            //openImageDialog.Multiselect = false;
            if (saveDataDialog.ShowDialog() == DialogResult.OK)
            {
                //if (saveDataDialog.FileName.EndsWith(".xlsx"))
                //    new Excell().WriteExcel_Table(saveDataDialog.FileName, mainForm.dataGridView_data);
                //else if (saveDataDialog.FileName.EndsWith(".txt") || saveDataDialog.FileName.EndsWith(".csv"))
                //ExportToExcelOrTxt(dataGridView1, saveDataDialog.FileName);
                rtb.SaveFile(saveDataDialog.FileName);
                MessageBox.Show("导出成功，文件路径为：" + saveDataDialog.FileName);
            }
            else
            { }
        }
    }
}
